home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / Filezilla Server / FileZilla_Server-0_9_41.exe / source / ServerThread.h < prev    next >
C/C++ Source or Header  |  2012-02-22  |  4KB  |  147 lines

  1. // FileZilla Server - a Windows ftp server
  2.  
  3. // Copyright (C) 2002-2004 - Tim Kosse <tim.kosse@gmx.de>
  4.  
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU General Public License
  7. // as published by the Free Software Foundation; either version 2
  8. // of the License, or (at your option) any later version.
  9.  
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14.  
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.  
  19. #if !defined(AFX_SERVERTHREAD_H__4F566540_62DF_4338_85DE_EC699EB6640C__INCLUDED_)
  20. #define AFX_SERVERTHREAD_H__4F566540_62DF_4338_85DE_EC699EB6640C__INCLUDED_
  21.  
  22. #include "Thread.h"
  23. #if _MSC_VER > 1000
  24. #pragma once
  25. #endif // _MSC_VER > 1000
  26. // ServerThread.h : Header-Datei
  27. //
  28.  
  29. class CControlSocket;
  30. class CServerThread;
  31. class COptions;
  32. class CPermissions;
  33. class t_user;
  34. class CExternalIpCheck;
  35. class CAutoBanManager;
  36. class CHashThread;
  37.  
  38. typedef struct
  39. {
  40.     CControlSocket *pSocket;
  41.     CServerThread *pThread;
  42. } t_socketdata;
  43.  
  44. /////////////////////////////////////////////////////////////////////////////
  45. // Thread CServerThread 
  46.  
  47. class CServerThread : public CThread
  48. {
  49. public:
  50.     virtual CStdString GetExternalIP(const CStdString& localIP);
  51.     virtual void ExternalIPFailed();
  52.     CServerThread(int nNotificationMessageId);
  53.  
  54.     CPermissions *m_pPermissions;
  55.     COptions *m_pOptions;
  56.     CAutoBanManager* m_pAutoBanManager;
  57.     void IncRecvCount(int count);
  58.     void IncSendCount(int count);
  59.     void IncIpCount(const CStdString &ip);
  60.     void DecIpCount(const CStdString &ip);
  61.     int GetIpCount(const CStdString &ip) const;
  62.     BOOL IsReady();
  63.     static const int GetGlobalNumConnections();
  64.     void AddSocket(SOCKET sockethandle, bool ssl);
  65.     const int GetNumConnections();
  66.  
  67.     struct t_Notification
  68.     {
  69.         WPARAM wParam;
  70.         LPARAM lParam;
  71.     };
  72.  
  73.     void SendNotification(WPARAM wParam, LPARAM lParam);
  74.  
  75.     /*
  76.      * The parameter should be an empty list, since m_pendingNotifications and 
  77.      * list get swapped to increase performance.
  78.      */
  79.     void GetNotifications(std::list<CServerThread::t_Notification>& list);
  80.  
  81.     void AntiHammerIncrease(const CStdString& ip);
  82.     
  83.     CHashThread& GetHashThread();
  84.  
  85. protected:
  86.     virtual ~CServerThread();
  87.  
  88.     void GatherTransferedBytes();
  89.     void ProcessNewSlQuota();
  90.     virtual BOOL InitInstance();
  91.     virtual DWORD ExitInstance();
  92.  
  93.     virtual int OnThreadMessage(UINT Msg, WPARAM wParam, LPARAM lParam);
  94.     void OnTimer(WPARAM wParam, LPARAM lParam);    
  95.     
  96.     void ProcessControlMessage(t_controlmessage *msg);
  97.     CControlSocket * GetControlSocket(int userid);
  98.     std::map<int, CControlSocket *> m_LocalUserIDs;
  99.     void AddNewSocket(SOCKET sockethandle, bool ssl);
  100.     static int CalcUserID();
  101.     static std::map<int, t_socketdata> m_userids;
  102.     static std::map<CStdString, int> m_userIPs;
  103.     void AntiHammerDecrease();
  104.  
  105.     int m_nRecvCount;
  106.     int m_nSendCount;
  107.     UINT m_nRateTimer;
  108.     BOOL m_bQuit;
  109.  
  110.     CCriticalSectionWrapper m_threadsync;
  111.     static CCriticalSectionWrapper m_GlobalThreadsync;
  112.     unsigned int m_timerid;
  113.  
  114.     //Speed limit code
  115.     static std::list<CServerThread *> m_sInstanceList; //First instance is the SL master
  116.     BOOL m_bIsMaster;
  117.     int m_nLoopCount;
  118.  
  119.     int m_lastLimits[2];
  120.     typedef struct {
  121.         long long nBytesAllowedToTransfer;
  122.         long long nTransferred;
  123.     } t_Quota;
  124.     t_Quota m_SlQuotas[2];
  125.  
  126.     CStdString m_RawWelcomeMessage;
  127.     std::list<CStdString> m_ParsedWelcomeMessage;
  128.     CExternalIpCheck *m_pExternalIpCheck;
  129.  
  130.     std::list<t_Notification> m_pendingNotifications;
  131.     int m_throttled;
  132.  
  133.     int m_nNotificationMessageId;
  134.  
  135.     static std::map<CStdString, int> m_antiHammerInfo;
  136.     int m_antiHammerTimer;
  137.  
  138.     static CHashThread* m_hashThread;
  139. };
  140.  
  141. /////////////////////////////////////////////////////////////////////////////
  142.  
  143. //{{AFX_INSERT_LOCATION}}
  144. // Microsoft Visual C++ fⁿgt unmittelbar vor der vorhergehenden Zeile zusΣtzliche Deklarationen ein.
  145.  
  146. #endif // AFX_SERVERTHREAD_H__4F566540_62DF_4338_85DE_EC699EB6640C__INCLUDED_
  147.